
import React from 'react';
import {Form, Row, Col, Button, DatePicker, message ,Divider,Select} from 'antd';
import StatisticsBox from '../../components/box/statistics';
import {sessionManager} from '../../utils/sessionStorage';
import AdjustHis from './AdjustHis';
import {injectIntl} from 'react-intl';
import Grid from '../../components/table/grid';
import tranStartType from '../../utils/tranStartType';
import axios from 'axios';
import moment from 'moment';
import { getYear } from '../../utils/Array';
import qs from 'qs';

class ledgerMonthDetail extends React.Component {
	constructor(props) {
		super(props);
		this.common = this.props.intl.messages.common;
		this.columns = [
			{
				title: '结算时间',
				width: '150',
				dataIndex:'settlementDate',
				key: 'settlementDate'
			},
			{
				title: '结算对象',
				dataIndex: 'settlementName',
				key: 'settlementName',
				width: '150',
			},
			{
				title: '电量（KWH）',
				dataIndex: 'power',
				key: 'power',
				width: '150',
			},
			{
				title: '电费（元）',
				dataIndex: 'feeElectric',
				key: 'feeElectric',
				width: '150',
			},
			{
				title: '服务费（元）',
				dataIndex: 'feeService',
				key: 'feeService',
				width: '150',
			},
			{
				title: '总费用',
				dataIndex: 'feeTotal',
				key: 'feeTotal',
				width: '150',
			},
			{
				title: this.common.operation,
				key: 'action',
				fixed: 'right',
				width: 100,
				render: (text, record) => (
					<span>
                        <a onClick={() => this.goLink(text, record, 'ledgerMonthMyOrderList')}>订单明细</a>
                    </span>
				)
			}
		];
		this.state = {
			params:{
				ym:''
			}
		}
	}

	componentWillMount() {
		if(this.props.location.state&&this.props.location.state.ym){
			this.setState({
				params:{
					ym:this.props.location.state.ym
				}
			})
		}else{
			this.setState({
				params:{
					ym:sessionManager.get('ym')
				}
			})
		}

	}

	goLink = (text, record, link) => {
		if(this.props.location.state){
			sessionManager.set('ym',this.props.location.state.ym);
		}
		sessionManager.set('settlementDate',text.settlementDate);
		this.props.history.push({pathname: `/finance/${link}`});
	};

	render() {
		return (
			<div>
				<Grid url="api/settlement/billSplit/myBillOrderDayDetail" columns={this.columns}   params={this.state.params}/>
			</div>
		)
	}
}

// ledgerMonthDetail = createForm()(ledgerMonthDetail);
export default injectIntl(ledgerMonthDetail)
